﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ecdl.demo.persistence;
using ecdl.demo.model.precondition;
using ecdl.demo.model.expression;

namespace ecdl.demo.model.file {
    public class FileTaskPersistenceContributor : IPersistenceContributor{

        public void ContributeTypesTypes(DTODeserializer serializer) {
            
            serializer.AddPreconditionElementAttribute(typeof(CreateFile), "CreateFile");
            serializer.AddPreconditionElementAttribute(typeof(CreateDirectory), "CreateDirectory");
            serializer.AddExpressionElementAttribute(typeof(FileExsistsConditionDTO), "FileExists");
            serializer.AddExpressionElementAttribute(typeof(FolderExistsConditionDTO), "FolderExists");
            serializer.AddExpressionElementAttribute(typeof(IsWriteProtectedConditionDTO), "IsWriteProtected");
            serializer.AddExpressionElementAttribute(typeof(FileExistsInZipConditionDTO), "FileExistsInZip");

            serializer.AddTaskElementAttribute(typeof(FileTaskDTO), "FileTask");
        }

        public void ContributeOverrides(DTODeserializer serializer) {
            serializer.AddAttributeOverride(typeof(FileTaskDTO), "Expression", serializer.GetExpressionXmlElementAttributes());
            serializer.AttributeOverrides.Add(typeof(FileTaskDTO), "Preconditions", serializer.GetPreconditionXmlArrayAttributes());

        }
    }
}
